// UserInput.h provides the attributes of the UserInput class
// list of DirectInput keywords
// http://msdn.microsoft.com/en-us/library/ee418641.aspx
//-----------------

#if !defined( UserInputH)
#define UserInputH

//-----------------
// Includes various libraries and files
#include <cassert>		// for asserts
#include <dinput.h>		// Direct Input library (for Direct Input function)

//-----------------

#define KEYDOWN( name, key) (name[key] & 0x80)

#define DIMOUSE_LEFTBUTTON		0
#define DIMOUSE_RIGHTBUTTON		1
#define DIMOUSE_MIDDLEBUTTON	2

class UserInput {
	public:
		// constructor and destructor
		UserInput();
		~UserInput();

		// accessor
		void get_mouse_movement( float& x, float& y) const;								// get the x and y position of the mouse
		void get_mouse_position( float& x, float& y, const int& w, const int& h) const;	// get the amount of movement in the x and y of the mouse
		float get_mouse_wheel_movement() const;											// get the amount of movement of the mouse wheel
		bool button_is_pressed( const int button) const;								// check if mouse button is pressed
		bool button_is_held( const int button) const;									// check if mouse button is held
		bool key_is_pressed( const int key) const;										// check if the key has just been pressed
		bool key_is_held( const int key) const;											// check if the key is being held down

		// mutator
		BOOL WINAPI setup_direct_input( HINSTANCE g_hinst, HWND g_hwndMain);
		void process_input();														// get the current key press
		char get_key_pressed();														// return the button that was pressed

	private:
		void WINAPI clean_up_direct_input();
		void WINAPI process_mouse_input();
		void WINAPI process_keyboard_input();

		DIMOUSESTATE2 mouse_state_current, mouse_state_prev;	// DirectInput mouse state structure
		char press_current[256];								// create a buffer to contain the key press data from the keyboard
		char press_prev[256];
		LPDIRECTINPUT8 g_pDI;									// point to the DirectInput object
		LPDIRECTINPUTDEVICE8 g_pDIMouseDevice;					// the DirectInput mouse device
		LPDIRECTINPUTDEVICE8 g_pDIKeyboardDevice;				// the DirectInput keyboard device
		int delay_;												// for adding a delay when keys are pressed
};

#endif